<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * 后台用户表
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('role_id')->comment('角色id')->default(0);
            $table->string('username' ,50)->comment('账号');
            $table->string('truename' ,50)->comment('真实姓名')->default('未知');
            $table->string('password' ,255)->comment('密码');
            $table->string('email' ,50)->comment('邮箱')->nullable();
            $table->string('phone' ,15)->comment('手机号码')->default('');
            $table->enum('sex' ,['先生', '女士'])->comment('性别')->default('先生');
            $table->char('last_ip' ,15)->comment('登陆ip')->default('');

            $table->timestamps();
            //软删除 生成deleted_at字段
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
